<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.softwarerusher.datastructure.Cart" %>



      <div class="cart">
       <div class="title">
          <span class="title_icon"><img src="images/cart.gif" alt="" title="" />
           </span>
           <%if(session.getAttribute("login") == "true") {%>
           <%=session.getAttribute("name") %>
           <a href = "netshop/logout">退出</a>
           <% }else{%>
             <a href = "myaccount.jsp">登陆</a>
            <%} %> 
            </div>
            <%if("true".equals(session.getAttribute("login"))){ %>
            
                   <%List<Cart> cart = (List<Cart>)session.getAttribute("cart"); %>
				      <%double sum = 0; %>
				      <%for(int i = 0 ;i<cart.size() ; i++) {%>
				      <%sum+=cart.get(i).getBook().getBookPrice() * cart.get(i).getNum(); }%>
				      <%sum = sum * (Double)session.getAttribute("discountRate");%>
             <div class="home_cart_content"> <%=cart.size() %>x 项目 | <span class="red">总共:
             <%if(String.valueOf(sum).length()>5){%>
              <%=String.valueOf(sum).substring(0,5) %>
             <%} else{%>
             <%=sum %>
             <%} %>
             </span> </div>
             <a href="cart.jsp" class="view_cart">查看购物车</a>
             <%} else{%>
             
             <%} %>
      </div>